package com.shiyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shiyi.system.entity.OperationLog;
import com.shiyi.system.mapper.OperationLogMapper;
import com.shiyi.system.service.OperationLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author shiyi
 * @since 2020-12-08
 */
@Service
@Transactional
public class OperationLogServiceImpl extends ServiceImpl<OperationLogMapper, OperationLog> implements OperationLogService {

    @Override
    public List<OperationLog> listLog(Integer type, String keyword) {
        QueryWrapper<OperationLog> wrapper = new QueryWrapper<>();
        if (type != null) {
            wrapper.eq("type", type);
        }
        if (keyword != null && !"".equals(keyword)) {
            wrapper.like("module", keyword);
            wrapper.like("real_name", keyword);
        }
        wrapper.orderByDesc("create_time");
        return list(wrapper);
    }
}
